package com.mini.constant;

/**
 * @author zhangxiaobin
 * @title: RedisKeyConst
 * @description: TODO
 * @date 2019/10/2716:45
 */
public class RedisKeyConst {

    /**
     * 用户信息缓存前缀
     */
    private static final String MINI_KEY_PREFIX ="mini:business";

    /**
     * redis中间前缀
     */
    private static final String REDIS_SPLIT_PRE = ":";
    /**
     * redis中间后缀
     */
    private static final String REDIS_SPLIT_SUFFIX = "_";

    private static final String TRADITIONAL_KEY_PREFIX="traditional:business";


    /**
     * 获取redis的key
     * @param pre
     * @param argArray
     * @return
     */
    private static String getMiniKeyArray(String pre, Object[] argArray){
        StringBuffer sb = new StringBuffer();
        sb.append(MINI_KEY_PREFIX + REDIS_SPLIT_PRE + pre);
        if(argArray != null && argArray.length != 0) {
            int start = 0;
            for(int i=0;i< argArray.length;i++){
                if(argArray[i]==null){
                    continue;
                }
                if(start==0){
                    sb.append(REDIS_SPLIT_PRE);
                }else {
                    sb.append(REDIS_SPLIT_SUFFIX);
                }
                sb.append(argArray[i]);
                start ++;
            }
        }
        return sb.toString();
    }


    /**
     * 获取redis的key
     * @param pre
     * @param argArray
     * @return
     */
    private static String getTraditionKeyArray(String pre,Object[] argArray){
        StringBuffer sb = new StringBuffer();
        sb.append(TRADITIONAL_KEY_PREFIX + REDIS_SPLIT_PRE + pre);
        if(argArray != null && argArray.length != 0) {
            int start = 0;
            for(int i=0;i< argArray.length;i++){
                if(argArray[i]==null){
                    continue;
                }
                if(start==0){
                    sb.append(REDIS_SPLIT_PRE);
                }else {
                    sb.append(REDIS_SPLIT_SUFFIX);
                }
                sb.append(argArray[i]);
                start ++;
            }
        }
        return sb.toString();
    }

    public static String getDeptFullNameKey(Long deptId) {
        return getTraditionKeyArray("DeptFullName",new Object[] {deptId});
    }

    public static String getUserSimpleInfoKey(Long userId) {
        return getTraditionKeyArray("UserSimpleInfo",new Object[] {userId});
    }

    public static String getFullDeptVo(Long deptId) {
        return getMiniKeyArray("FullDeptVo",new Object[] {deptId});
    }

    public static String getDeptLevelDic(Integer skuType,String key) {
        return getMiniKeyArray("DeptLevelDic",new Object[] {skuType,key});
    }

    public static String getDeptRLevelDic(String key) {
        return getMiniKeyArray("DeptRLevelDic",new Object[] {key});
    }

    public static String getUserDeptFullNameKey(Long userId) {
        return getMiniKeyArray("UserDeptFullName",new Object[] {userId});
    }

    public static String getDeptNameKey(Long deptId) {
        return getMiniKeyArray("DeptName",new Object[] {deptId});
    }

    public static String getDeptNameKeyByDeptId(Long deptId) {
        return getMiniKeyArray("DeptIds",new Object[] {deptId});
    }

    public static String getDeptNameKeyByUserId(Long userId) {
        return getMiniKeyArray("DeptNameUserId",new Object[] {userId});
    }

    public static String getUserDeptNameKey(Long userId) {
        return getMiniKeyArray("UserDeptName",new Object[] {userId});
    }



//    某量子军团某天的需求规划
    public static String getRequirementPlan(Object... objects){
        return getTraditionKeyArray("RequirementPlan",objects);
    }

    private static final String BUSINESS_NEW_FLAG = "business_new_flag";
    public static String getBusinessNewFlag(Object... objects) {
        return getTraditionKeyArray(BUSINESS_NEW_FLAG, objects);
    }


    //小课／传统 业务用户最后记录key
    private static final String ZH_LastState_KEY = "zh_laststate";
    public static String getZHLastState(Object... objects){
        return getTraditionKeyArray(ZH_LastState_KEY, objects);
    }


    private static final String BUSINESS_INFO = "business:info";
    public static String getBusinessInfo(Object... objects) {
        return getTraditionKeyArray(BUSINESS_INFO,objects);//mini:business:business:info:
    }

    /**
     * 小课页面
     */
    private static final String BUSINESS_PAGE_SITE = "business_page_site";
    public static String getBusinessPageSite(Object... objects) {
        return getTraditionKeyArray(BUSINESS_PAGE_SITE,objects);
    }


    private static final String PLAN_INFO="plan_info";
    public static String getPlanInfo(Long planSite) {
        return getTraditionKeyArray(PLAN_INFO, new Object[] {planSite});
    }
    private static final String PLAN_SITE_PAGE="plan_site_page";
    public static String getPlanSitePage(Long planSite) {
        return getTraditionKeyArray(PLAN_SITE_PAGE, new Object[] {planSite});
    }
    private static final String PLAN_HISOTORY="plan_hisotory";
    public static String getPlanHisotory(Long planSite) {
        return getTraditionKeyArray(PLAN_HISOTORY, new Object[] {planSite});
    }
    public static final String PLAN_NEXTDAYLESSONSITE="plan_nextdayLessonsite";

    /**
     * 主体信息列表
     */
    private static final String COMPANY_INFO_LIST_KEY = "company:info:list";
    public static String getCompanyInfoListKey(Object... objects) {
        return getTraditionKeyArray(COMPANY_INFO_LIST_KEY,objects);
    }

    /**
     * 公司主体信息
     */
    private static final String COMPANY_INFO_KEY = "company:info" ;
    public static String getCompanyInfoKey(Object... objects) {
        return getTraditionKeyArray(COMPANY_INFO_KEY,objects);
    }

    private static final String OPREATION_LOCK = "opreation-lock";
    public static String getOpreationLock(Object... objects) {
        return getTraditionKeyArray(OPREATION_LOCK,objects) ;
    }


    /**
     * 运营专员信息key
     */
    private static final String TEACHER_INFO = "teacher:info";
    public static String getTeacherInfo(Object... objects) {
        return getTraditionKeyArray(TEACHER_INFO,objects);
    }

    /**
     * 运营专员列表key，每个组的组员信息
     */
    private static final String TEACHER_INFO_LIST_GROUP = "teacher:list:group";
    public static String getTeacherInfoListGroup(Object... objects) {
        return getTraditionKeyArray(TEACHER_INFO_LIST_GROUP,objects);
    }

    /**
     * 运营专员列表key，每个组的组员信息
     */
    private static final String TEACHER_INFO_LIST_DEPT = "teacher:list:dept";
    public static String getTeacherInfoListDept(Object... objects) {
        return getTraditionKeyArray(TEACHER_INFO_LIST_DEPT,objects);
    }

    /**
     * 工作室对应的组id
     */
    private static final String TEACHER_GROUP_IDS_BY_DEPT_ID = "teacher:deptId:groupIds";
    public static String getTeacherGroupIdsByDeptId(Object... objects) {
        return getTraditionKeyArray(TEACHER_GROUP_IDS_BY_DEPT_ID,objects);
    }
    private static final String TEACHER_WECHAT_INFO_LIST = "teacher:wechat:list";
    public static String getTeacherWechatInfoList(Object... objects) {
        return getTraditionKeyArray(TEACHER_WECHAT_INFO_LIST,objects);
    }

    /**
     * 修改销售组
     */
    public static String getBelongIngKey(Object... objects) {
        return getTraditionKeyArray("belonging:lock",objects);
    }

}
